package com.ruoyi.steel_warehouse_zlw.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.steel_warehouse_zlw.domain.ZlwSteelWarehouse;
import com.ruoyi.steel_warehouse_zlw.service.IZlwSteelWarehouseService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 钢材-仓库关系信息Controller
 * 
 * @author zlw
 * @date 2025-06-11
 */
@Controller
@RequestMapping("/steel_warehouse_zlw/warehouse")
public class ZlwSteelWarehouseController extends BaseController
{
    private String prefix = "steel_warehouse_zlw/warehouse";

    @Autowired
    private IZlwSteelWarehouseService zlwSteelWarehouseService;

    @RequiresPermissions("steel_warehouse_zlw:warehouse:view")
    @GetMapping()
    public String warehouse()
    {
        return prefix + "/warehouse";
    }

    /**
     * 查询钢材-仓库关系信息列表
     */
    @RequiresPermissions("steel_warehouse_zlw:warehouse:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ZlwSteelWarehouse zlwSteelWarehouse)
    {
        startPage();
        List<ZlwSteelWarehouse> list = zlwSteelWarehouseService.selectZlwSteelWarehouseList(zlwSteelWarehouse);
        return getDataTable(list);
    }

    /**
     * 导出钢材-仓库关系信息列表
     */
    @RequiresPermissions("steel_warehouse_zlw:warehouse:export")
    @Log(title = "钢材-仓库关系信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ZlwSteelWarehouse zlwSteelWarehouse)
    {
        List<ZlwSteelWarehouse> list = zlwSteelWarehouseService.selectZlwSteelWarehouseList(zlwSteelWarehouse);
        ExcelUtil<ZlwSteelWarehouse> util = new ExcelUtil<ZlwSteelWarehouse>(ZlwSteelWarehouse.class);
        return util.exportExcel(list, "钢材-仓库关系信息数据");
    }

    /**
     * 新增钢材-仓库关系信息
     */
    @RequiresPermissions("steel_warehouse_zlw:warehouse:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存钢材-仓库关系信息
     */
    @RequiresPermissions("steel_warehouse_zlw:warehouse:add")
    @Log(title = "钢材-仓库关系信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ZlwSteelWarehouse zlwSteelWarehouse)
    {
        return toAjax(zlwSteelWarehouseService.insertZlwSteelWarehouse(zlwSteelWarehouse));
    }

    /**
     * 修改钢材-仓库关系信息
     */
    @RequiresPermissions("steel_warehouse_zlw:warehouse:edit")
    @GetMapping("/edit/{steelId}")
    public String edit(@PathVariable("steelId") String steelId, ModelMap mmap)
    {
        ZlwSteelWarehouse zlwSteelWarehouse = zlwSteelWarehouseService.selectZlwSteelWarehouseBySteelId(steelId);
        mmap.put("zlwSteelWarehouse", zlwSteelWarehouse);
        return prefix + "/edit";
    }

    /**
     * 修改保存钢材-仓库关系信息
     */
    @RequiresPermissions("steel_warehouse_zlw:warehouse:edit")
    @Log(title = "钢材-仓库关系信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ZlwSteelWarehouse zlwSteelWarehouse)
    {
        return toAjax(zlwSteelWarehouseService.updateZlwSteelWarehouse(zlwSteelWarehouse));
    }

    /**
     * 删除钢材-仓库关系信息
     */
    @RequiresPermissions("steel_warehouse_zlw:warehouse:remove")
    @Log(title = "钢材-仓库关系信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(zlwSteelWarehouseService.deleteZlwSteelWarehouseBySteelIds(ids));
    }
}
